//
//  input2ViewController.m
//  IOS6
//
//  Created by blue on 15-11-30.
//  Copyright (c) 2015年 zx. All rights reserved.
//

#import "input2ViewController.h"


@interface input2ViewController ()<UITextFieldDelegate>
{
    UITextField * tfname;
    UITextField * tftel;
}
@end
@interface myItem : NSObject <UIActivityItemSource>
@property (strong,nonatomic)NSString * text;


@end
@implementation myItem
- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController
{
    return self.text;
}

- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType
{
    return self.text;
}

@end
@implementation input2ViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    tfname = [[UITextField alloc]initWithFrame:CGRectMake(16, 0, self.view.frame.size.width - 16, 44)];
     tftel= [[UITextField alloc]initWithFrame:CGRectMake(16, 0, self.view.frame.size.width - 16, 44)];
    tfname.text = self.tfname1;
    tftel.text = self.tftel1;
    tfname.delegate = self;
    tftel.delegate = self;
  //  self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(save:)];
    UIBarButtonItem * bth = [[UIBarButtonItem alloc]initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(save:)];
    UIBarButtonItem * bth2 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(onclik:)];
    self.navigationItem.rightBarButtonItems = @[bth , bth2];
     
}

- (void)onclik:(id )bar2
{
    myItem * Item = [myItem new];
    Item.text = @"hi";
    UIActivityViewController * con = [[UIActivityViewController alloc]initWithActivityItems:@[Item] applicationActivities:nil];
    [self presentViewController:con animated:YES completion:nil];
    
}

- (void)save:(id)bar
{
    [self.delegate InputFishWithname:tfname.text tel:tftel.text];
    [self.navigationController popToViewController:self animated:YES];
    [self.navigationController popToRootViewControllerAnimated:YES];
}


- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [tfname becomeFirstResponder];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField restorationIdentifier];
    return YES;
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    UITableViewCell * cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
     

    [cell.contentView addSubview:indexPath.section ==0?tfname: tftel];
    return cell;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return @[@"姓名",@"电话"][section];
}




- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
